/*
 * Created by Jesse Phillips
 * Created on 12-Jan-06
 */

public abstract class TwoDShape implements Comparable {
	protected String name;
	
	private TwoDShape() {
		name = "2D Shape";
	}
	
	protected TwoDShape(String name) {
		this.name = name;
	}
	
	public abstract double area();
	
	public abstract double perimeter();
	
	public static boolean validate(double side) {
		if(side > 0) 
			return true;
		else
			return false;
	}
	
	public String getName() {
		return name;
	}
	
	public int compareTo(Object o) {
		TwoDShape other = null;
		try {
			other = (TwoDShape) o;
		}catch(ClassCastException cce) {
			System.out.println("Not a TwoDShape.");
			System.exit(1);
		}
		if(this.name.compareTo(other.getName()) == 0) {
			if(this.area() > other.area())
				return 1;
			else if(this.area() < other.area())
				return -1;
			else
				return 0;
		}else
			return this.name.compareTo(other.getName());
	}
	
	public String toString() {
		return name+"\nParameter: "+perimeter()+"\nArea: "+area();
	}
}
